// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
  return request<API.CurrentUser>('/api/currentUser', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 登出接口 POST /api/logout */
export async function outLogin(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/logout', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 登录接口 POST /api/login */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
  return request<API.LoginResult>('/api/login', {
    method: 'POST',
    data: body,
    requestType: 'form',
    ...(options || {}),
  });
}

/** 获取用户列表 GET /api/user */
export async function queryUser(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RequestData>('/api/user', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 获取用户列表 GET /api/user */
export async function userList(
  params?: any,
  options?: { [key: string]: any },
) {
  return request<API.UserItem[]>('/api/user', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 更新用户 PUT /api/user */
export async function updateUser(body: API.UserItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/user', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}



/** 添加用户 POST /api/user */
export async function addUser(body: API.UserItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/user', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除用户 DELETE /api/user */
export async function removeUser(
  params: {
    // query
    /** 用户Id */
    userId?: number;
  },
  options?: { [key: string]: any },
) {
  return request<Record<string, any>>('/api/user', {
    method: 'DELETE',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 删除用户DELETE  */
export async function batchRemoveUser(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/user/batchdel', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}

export async function validUserName(params: any) {
  return request('/api/validUserName', {
    params,
  });
}

export async function validPassWord(params: any) {
  return request('/api/user/validPassWord', {
    params,
  });
}

export async function countByRole(params: any) {
  return request('/api/user/countByRole', {
    params,
  });
}





/** 修改密码密码 PUT /api/user */
export async function updatePassword(body: API.UserItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/user/updatePassword', {
    method: 'PUT',
    requestType:'form',
    data: body,
    ...(options || {}),
  });
}
